package com.inews;

import javax.sql.DataSource;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.transaction.TransactionConfiguration;

import com.inews.base.mapper.JsonMapper;
import com.inews.base.security.vo.BaseUserVo;
import com.inews.base.vo.ExtData;

@ContextConfiguration(locations = { "/applicationContext.xml"})
@TransactionConfiguration(defaultRollback=false)
public abstract class SpringTransactionalTestCase extends AbstractTransactionalJUnit4SpringContextTests {

	private static Logger logger = Logger.getLogger(SpringTransactionalTestCase.class);
	
	protected DataSource dataSource;

	@Override @Autowired
	public void setDataSource(DataSource dataSource) {
		super.setDataSource(dataSource);
		this.dataSource = dataSource;
	}
	
	
	public BaseUserVo getBaseUserVo(){
		BaseUserVo vo = new BaseUserVo();
		vo.setUserId(1L);
		return vo;
	}
	
	
	public void printJSON(ExtData<?> extData){
		String json = JsonMapper.nonEmptyMapper().toJson(extData);
		logger.info(json);
	}
	
}
